home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Controls / Visual Basic Controls.iso / vbcontrol / axcool / modpaint.bas < prev    next >
BASIC Source File  |  1998-10-19  |  8KB  |  165 lines

  1. Attribute VB_Name = "modPaint"
  2. '*****************************************************************
  3. '
  4. '   axcoolbutton CONTROL
  5. '
  6. '   This code and control is absolutely freeware!
  7. '
  8. '   You have a royalty-free right to use, modify, reproduce and distribute
  9. '   the source code and control (and/or any modified version) in any way
  10. '   you find useful, provided that you agree that the authors have no warranty,
  11. '   obligations or liability for any code distributed in this project group.
  12. '
  13. ' Copyright ⌐ 1998 by Geoff Glaze
  14. '
  15. '   (Some parts borrowed from Microsoft)
  16. '
  17. '*****************************************************************
  18.  
  19. '-------------------------------------------------------------------------
  20. 'This module provides some needed Type, API, and Constant declarations
  21. '-------------------------------------------------------------------------
  22.  
  23. Option Explicit
  24.  
  25. Public Type POINTAPI
  26.     x As Long
  27.     y As Long
  28. End Type
  29.  
  30. Public Type RECT
  31.     Left As Long
  32.     Top As Long
  33.     Right As Long
  34.     Bottom As Long
  35. End Type
  36.  
  37. Public Type BITMAPINFOHEADER '40 bytes
  38.         biSize As Long
  39.         biWidth As Long
  40.         biHeight As Long
  41.         biPlanes As Integer
  42.         biBitCount As Integer
  43.         biCompression As Long
  44.         biSizeImage As Long
  45.         biXPelsPerMeter As Long
  46.         biYPelsPerMeter As Long
  47.         biClrUsed As Long
  48.         biClrImportant As Long
  49. End Type
  50.  
  51. Public Type RGBQUAD
  52.         rgbBlue As Byte
  53.         rgbGreen As Byte
  54.         rgbRed As Byte
  55.         rgbReserved As Byte
  56. End Type
  57.  
  58. Public Type BITMAPINFO
  59.         bmiHeader As BITMAPINFOHEADER
  60.         bmiColors(1) As RGBQUAD
  61. End Type
  62.  
  63. Public Declare Function DrawIcon Lib "user32" (ByVal hDC As Long, ByVal x As Long, ByVal y As Long, ByVal hIcon As Long) As Long
  64. Public Declare Function CreateSolidBrush Lib "gdi32" (ByVal crColor As Long) As Long
  65. Public Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
  66. Public Declare Function SetBkColor Lib "gdi32" (ByVal hDC As Long, ByVal crColor As Long) As Long
  67. Public Declare Function CreateCompatibleDC Lib "gdi32" (ByVal hDC As Long) As Long
  68. Public Declare Function DeleteDC Lib "gdi32" (ByVal hDC As Long) As Long
  69. Public Declare Function CreateCompatibleBitmap Lib "gdi32" (ByVal hDC As Long, ByVal nWidth As Long, ByVal nHeight As Long) As Long
  70. Public Declare Function SelectObject Lib "gdi32" (ByVal hDC As Long, ByVal hObject As Long) As Long
  71. Public Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
  72. Public Declare Function FillRect Lib "user32" (ByVal hDC As Long, lpRect As RECT, ByVal hBrush As Long) As Long
  73. Public Declare Function GetDC Lib "user32" (ByVal hWnd As Long) As Long
  74. Public Declare Function GetPixel Lib "gdi32" (ByVal hDC As Long, ByVal x As Long, ByVal y As Long) As Long
  75. Public Declare Function SetTextColor Lib "gdi32" (ByVal hDC As Long, ByVal crColor As Long) As Long
  76. Public Declare Function CreateBitmap Lib "gdi32" (ByVal nWidth As Long, ByVal nHeight As Long, ByVal nPlanes As Long, ByVal nBitCount As Long, lpBits As Any) As Long
  77. Public Declare Function GetBkColor Lib "gdi32" (ByVal hDC As Long) As Long
  78. Public Declare Function GetTextColor Lib "gdi32" (ByVal hDC As Long) As Long
  79. Public Declare Function SelectPalette Lib "gdi32" (ByVal hDC As Long, ByVal hPalette As Long, ByVal bForceBackground As Long) As Long
  80. Public Declare Function RealizePalette Lib "gdi32" (ByVal hDC As Long) As Long
  81. Public Declare Function ReleaseDC Lib "user32" (ByVal hWnd As Long, ByVal hDC As Long) As Long
  82. Public Declare Function CreateHalftonePalette Lib "gdi32" (ByVal hDC As Long) As Long
  83. Public Declare Function OleTranslateColor Lib "oleaut32.dll" (ByVal lOleColor As Long, ByVal lHPalette As Long, lColorRef As Long) As Long
  84. Public Declare Function CreateDIBSection Lib "gdi32" (ByVal hDC As Long, pBitmapInfo As BITMAPINFO, ByVal un As Long, ByVal lplpVoid As Long, ByVal handle As Long, ByVal dw As Long) As Long
  85. Public Declare Function SetDIBColorTable Lib "gdi32" (ByVal hDC As Long, ByVal un1 As Long, ByVal un2 As Long, pcRGBQuad As RGBQUAD) As Long
  86. Public Declare Function SetMapMode Lib "gdi32" (ByVal hDC As Long, ByVal nMapMode As Long) As Long
  87. Public Declare Function GetMapMode Lib "gdi32" (ByVal hDC As Long) As Long
  88. Public Declare Function DrawIconEx Lib "user32" (ByVal hDC As Long, ByVal xLeft As Long, ByVal yTop As Long, ByVal hIcon As Long, ByVal cxWidth As Long, ByVal cyHeight As Long, ByVal istepIfAniCur As Long, ByVal hbrFlickerFreeDraw As Long, ByVal diFlags As Long) As Long
  89. Public Declare Function CreatePatternBrush Lib "gdi32" (ByVal hBitmap As Long) As Long
  90.  
  91. Public Declare Function GetClientRect Lib "user32" (ByVal hWnd As Long, lpRect As RECT) As Long
  92. Public Declare Function DrawEdge Lib "user32" (ByVal hDC As Long, qrc As RECT, ByVal edge As Long, ByVal grfFlags As Long) As Long
  93. Public Declare Function InflateRect Lib "user32" (lpRect As RECT, ByVal x As Long, ByVal y As Long) As Long
  94.  
  95. ' DrawState used for greyscale conversions
  96. Public Declare Function DrawState Lib "user32" Alias "DrawStateA" (ByVal hDC As Long, ByVal hBrush As Long, ByVal lpDrawStateProc As Long, ByVal lParam As Long, ByVal wParam As Long, ByVal n1 As Long, ByVal n2 As Long, ByVal n3 As Long, ByVal n4 As Long, ByVal un As Long) As Long
  97.  
  98. 'DrawEdge constants
  99. Public Const BDR_INNER = &HC
  100. Public Const BDR_OUTER = &H3
  101. Public Const BDR_RAISED = &H5
  102. Public Const BDR_RAISEDINNER = &H4
  103. Public Const BDR_RAISEDOUTER = &H1
  104. Public Const BDR_SUNKEN = &HA
  105. Public Const BDR_SUNKENINNER = &H8
  106. Public Const BDR_SUNKENOUTER = &H2
  107.  
  108. Public Const EDGE_BUMP = (BDR_RAISEDOUTER Or BDR_SUNKENINNER)
  109. Public Const EDGE_ETCHED = (BDR_SUNKENOUTER Or BDR_RAISEDINNER)
  110. Public Const EDGE_RAISED = (BDR_RAISEDOUTER Or BDR_RAISEDINNER)
  111. Public Const EDGE_SUNKEN = (BDR_SUNKENOUTER Or BDR_SUNKENINNER)
  112.  
  113. Public Const BF_BOTTOM = &H8
  114. Public Const BF_LEFT = &H1
  115. Public Const BF_RIGHT = &H4
  116. Public Const BF_TOP = &H2
  117. Public Const BF_TOPLEFT = (BF_TOP Or BF_LEFT)
  118. Public Const BF_BOTTOMRIGHT = (BF_BOTTOM Or BF_RIGHT)
  119. Public Const BF_RECT = (BF_LEFT Or BF_TOP Or BF_RIGHT Or BF_BOTTOM)
  120.  
  121. Public Const BF_MIDDLE = &H800      'fill in the middle
  122. Public Const BF_SOFT = &H1000        'use for softer buttons
  123. Public Const BF_FLAT = &H4000         'for flat rather than 3d borders
  124. Public Const BF_MONO = &H8000       'for monoschrome borders (actually works better for flat borders)
  125.  
  126. 'DrawIconEx Flags
  127. Public Const DI_MASK = &H1
  128. Public Const DI_IMAGE = &H2
  129. Public Const DI_NORMAL = &H3
  130. Public Const DI_COMPAT = &H4
  131. Public Const DI_DEFAULTSIZE = &H8
  132.  
  133. 'DIB Section constants
  134. Public Const BI_RGB = 0&
  135. Public Const DIB_RGB_COLORS = 0 '  color table in RGBs
  136.  
  137.  
  138. 'Raster Operation Codes
  139. Public Const DSna = &H220326 '0x00220326
  140.  
  141. 'VB Errors
  142. Public Const giINVALID_PICTURE As Integer = 481
  143.  
  144.  
  145. ' Constant for GetPixel
  146. Public Const CLR_INVALID = &HFFFF
  147.  
  148.  
  149. ' DrawState constants
  150. Public Const DSS_DISABLED = &H20
  151. Public Const DSS_MONO = &H80
  152. Public Const DSS_NORMAL = &H0
  153. Public Const DSS_RIGHT = &H8000
  154. Public Const DSS_UNION = &H10
  155. Public Const DST_BITMAP = &H4
  156. Public Const DST_COMPLEX = &H0
  157. Public Const DST_ICON = &H3
  158. Public Const DST_PREFIXTEXT = &H2
  159. Public Const DST_TEXT = &H1
  160.  
  161. 'A few comments:
  162. '-The lparam is the picture property of the source Picture.
  163. '-If the picture is an icon use un=DST_ICON Or DSS_DISABLED, and if it's a
  164. 'bitmap use un=DST_BITMAP Or DSS_DISABLED
  165.